#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
using namespace std;
#include <vector>

struct TreeNode {
    int val;
    TreeNode* left;
    TreeNode* right;
    TreeNode() : val(0), left(nullptr), right(nullptr) {}
};

bool isValidBST(TreeNode* root);
void traversal(TreeNode* root, vector<int>& tmp);

void traversal(TreeNode* root, vector<int>& tmp) {
    if (root == nullptr)
        return;
    traversal(root->left, tmp);
    tmp.push_back(root->val);
    traversal(root->right, tmp);
}

bool isValidBST(TreeNode* root) {
    vector<int> tmp;
    traversal(root, tmp);
    for (int i = 0; i < tmp.size() - 1; i++) {
        if (tmp[i] >= tmp[i + 1])
            return false;
    }
    return true;

}


int main()
{
    
    TreeNode* t1 = new TreeNode();
    t1->val = 2;
    t1->left = new TreeNode();
    t1->left->val = 1;
    t1->right = new TreeNode();
    t1->right->val = 3;
    cout << isValidBST(t1);
    return 0;
}